<template>
            <van-list v-model="loading" :immediate-check="false" class="nowPlayingList-wrap" :finished="finished" finished-text="没有更多了" @load="onLoad">
                <ul class="nowPlayingList">
                    <van-cell >
                        <li v-for=" data in filmitems" class="nowPlayingFilm-item" :key="data.filmId">
                            <a @click="sendid(data.filmId)" href="javascript:void(0)" class="nowPlayingFilm-wrap">
                                <div   class="lazy-img nowPlayingFilm-img" style="width: 66px; height: 94px; background: rgb(249, 249, 249); float: left;">
                                    <div class="padding" style="width: 66px; height: 94px; background: rgb(249, 249, 249);">
                                        <!-- <img src="https://assets.maizuo.com/h5/v5/public/app/img/maizuo_padding.7c6a7f11.png" alt="" width="64px"> -->
                                         <img :src="data.poster" width="100%">
                                    </div>
                                    <div class="lazy-img-wrap" style="width: 66px; height: 94px; background: rgb(249, 249, 249); opacity: 1; display: block;">
                                        <!-- <img :src="data.poster" width="100%"> -->
                                    </div>
                                </div>
                                <div   class="nowPlayingFilm-info" style="float: left;">
                                    <div class="nowPlayingFilm-name info-col">
                                        <span class="name">{{data.name}}</span>
                                        <span class="item">{{data.filmType.name}}</span>
                                    </div>
                                    <div class="nowPlayingFilm-grade info-col" style="visibility: visible;">
                                        <span class="label">观众评分： </span>
                                        <span :class="data.grade? 'grade' :'no-score'">{{data.grade |gradefilter}}</span>
                                    </div>
                                    <div class="nowPlayingFilm-name info-col">
                                        <span class="label">主演：{{data.actors | actorsfilter}}</span>
                                    </div>
                                    <div class="nowPlayingFilm-name info-col">
                                        <span class="label">{{data.nation}} | {{data.runtime}}分钟</span>
                                    </div>
                                </div>
                                <div class="nowPlayingFilm-buy" style="float: right;">
                                    购票
                                </div>
                            </a>
                        </li>
                    </van-cell>
                </ul>
            </van-list>
</template>
<style scoped>
.nowPlayingList-wrap ul {
    list-style: none;
    padding: 0;
    margin-left: 15px;
    margin-bottom: 0;
    margin-top: 0;
}
.nowPlayingList-wrap {
    background-color: #fff;
}
.nowPlayingList-wrap li {
    padding: 20px 15px 15px 0;
    height: 94px;
    position: relative;
}
.no-score {
    width: 60px;
    height: 17px;
    font-size: 12px;
    color: #999;
    line-height: 17px;
    display: inline-block;
    text-align: center;
}
.nowPlayingList-wrap li .nowPlayingFilm-wrap {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: start;
    -ms-flex-pack: start;
    justify-content: flex-start;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}
.nowPlayingList-wrap li:after {
    content: " ";
    position: absolute;
    left: 0;
    bottom: 0;
    right: 0;
    height: 1px;
    border-bottom: 1px solid #ededed;
    color: #ededed;
    -webkit-transform-origin: 0 100%;
    -ms-transform-origin: 0 100%;
    transform-origin: 0 100%;
    -webkit-transform: scaleY(.5);
    -ms-transform: scaleY(.5);
    transform: scaleY(.5);
}
.lazy-img {
    position: relative;
}
.lazy-img .lazy-img-wrap[data-v-21c202bd], .lazy-img .padding[data-v-21c202bd] {
    height: 56vw;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}
.nowPlayingList-wrap li .nowPlayingFilm-wrap .nowPlayingFilm-img .lazy-img-wrap, .nowPlayingList-wrap li .nowPlayingFilm-wrap .nowPlayingFilm-img img {
    border-radius: 2px;
}
.nowPlayingList-wrap li .nowPlayingFilm-info .nowPlayingFilm-name span {
    display: inline-block;
    vertical-align: middle;
}
.lazy-img .lazy-img-wrap .target-img {
    width: 100%;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    -moz-transform: translateY(-50%);
    -webkit-transform: translateY(-50%);
    -o-transform: translateY(-50%);
}
.nowPlayingList-wrap li .nowPlayingFilm-info {
    width: calc(100% - 116px);
    padding: 0 10px;
}
.nowPlayingList-wrap li .nowPlayingFilm-info .info-col {
    text-overflow:ellipsis;
    -o-text-overflow: ellipsis;
    overflow:hidden;
    white-space:nowrap;
    width: 100%;
}
.nowPlayingList-wrap li .nowPlayingFilm-info .nowPlayingFilm-name .name {
    max-width: calc(100% - 25px);
    color: #191a1b;
    font-size: 16px;
    height: 22px;
    line-height: 22px;
    margin-right: 5px;
    overflow: hidden;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nowPlayingList-wrap li .nowPlayingFilm-info .nowPlayingFilm-name .item {
    font-size: 9px;
    color: #fff;
    background-color: #d2d6dc;
    height: 14px;
    line-height: 14px;
    padding: 0 2px;
    border-radius: 2px;
}
.nowPlayingList-wrap li .nowPlayingFilm-info .nowPlayingFilm-name {
    display: inline-block;
    vertical-align: middle;
}
.nowPlayingList-wrap li .nowPlayingFilm-info .label {
    font-size: 13px;
    margin-top: 4px;
    color: #797d82;
}
div {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    display: block;
}
.nowPlayingList-wrap li .nowPlayingFilm-info .nowPlayingFilm-grade .grade {
    color: #ffb232;
    font-size: 14px;
}
.nowPlayingList-wrap li .nowPlayingFilm-buy {
    line-height: 25px;
    height: 25px;
    width: 50px;
    color: #ff5f16;
    font-size: 13px;
    text-align: center;
    border-radius: 2px;
    position: relative;
}
.nowPlayingList-wrap li .nowPlayingFilm-buy:after {
    content: " ";
    -webkit-transform: scale(.5);
    -ms-transform: scale(.5);
    transform: scale(.5);
    position: absolute;
    border: 1px solid #ff5f16;
    top: -50%;
    right: -50%;
    bottom: -50%;
    left: -50%;
    border-radius: 4px;
}
.nowPlayingList-wrap li:after {
    content: " ";
    position: absolute;
    left: 0;
    bottom: 0;
    right: 0;
    height: 1px;
    border-bottom: 1px solid #ededed;
    color: #ededed;
    -webkit-transform-origin: 0 100%;
    -ms-transform-origin: 0 100%;
    transform-origin: 0 100%;
    -webkit-transform: scaleY(.5);
    -ms-transform: scaleY(.5);
    transform: scaleY(.5);
}
.van-cell{
    padding: 0;
}
</style>
<script>
import Vue from 'vue'
import http from '@/Util/http'
import { Cell, List } from 'vant'
import {mapState} from 'vuex'
Vue.use(List).use(Cell)
// import BetterScroll from 'better-scroll'
Vue.filter('actorsfilter', (actors) => {
  if (!actors) {
    actors = '暂无主演'
  } else {
    return actors.map(item => item.name).join(' ')
  }
})
Vue.filter('gradefilter', (data) => {
  if (!data) {
    return '暂无评分'
  } else {
    return data
  }
})
export default {

  data () {
    return {
      filmitems: [],
      finished: false,
      loading: false,
      current: 1,
      total: 0,
      actors: ['暂无主演']
    }
  },
   computed:{
      ...mapState('City',['Cityid'])
  },
  mounted () {
    http({
      url: `/gateway?cityId=${this.Cityid}&pageNum=1&pageSize=10&type=1&k=1335803`,
      headers: {
        'X-Host': 'mall.film-ticket.film.list'
      },
      method: 'get'
    }).then(res => {
      this.filmitems = res.data.data.films
    //   this.total = res.data.data.total
    })
    // this.$nextTick(() => {
    //   new BetterScroll('.nowPlayingList', {
    //     scrollball: {
    //       fade: true
    //     }
    //   })
    // })
  },
  methods: {
    
    sendid (filmId) {
      this.$router.push(`/Detail/${filmId}`)
      console.log(filmId)
    },
    onLoad () {
      console.log(this.total)
      console.log(this.filmitems.length)
      if (this.filmitems.length === this.total) {
        // console.log(this.filmitems)
        console.log(this.total)
        this.finished = true
        return
      }
      this.current++
      http({
        url: `/gateway?cityId=${this.Cityid}&pageNum=${this.current}&pageSize=10&type=1&k=1335803`,
        headers: {
          'X-Host': 'mall.film-ticket.film.list'
        }
      }).then(res => {
        this.filmitems = [...this.filmitems, ...res.data.data.films]
        this.total = res.data.data.total
        this.loading = false
      })
    }
  }
}
</script>
